package com.zprmb.udzt.adapter;

import java.text.DecimalFormat;
import java.util.List;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.zprmb.udzt.R;
import com.zprmb.udzt.bean.ExOutRecord;
import com.zprmb.udzt.util.Regular;

public class DexteritRecordAdapter extends BaseAdapter {
	private Context context;
    private List<ExOutRecord> list;
    DecimalFormat df = new DecimalFormat("###0.00");
	
	public DexteritRecordAdapter(Context context, List<ExOutRecord> list) {
		super();
		this.context = context;
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@SuppressLint("ViewHolder")
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		Help h=null;
		if(convertView==null){
			h=new Help();
			convertView=LayoutInflater.from(context).inflate(R.layout.out_record_item, null);
			h.tv_amount=(TextView) convertView.findViewById(R.id.tv_amount);
			h.tv_date=(TextView)convertView.findViewById(R.id.tv_date);
			h.tv_type=(TextView)convertView.findViewById(R.id.tv_type);
			convertView.setTag(h);
		}else{
			h=(Help) convertView.getTag();
		}
		h.tv_amount.setText("-"+df.format(Double.parseDouble(list.get(position).getTransferOutAmount())));
		h.tv_date.setText(Regular.getMilliTotime3(list.get(position).getRecordTime()));
		h.tv_type.setText("转出");
		return convertView;
	}
	class Help{
		private TextView tv_type,tv_date,tv_amount;
	}

}
